{include file="common/header-top" /}

<style>
    .step-span{
        font-size: 14px;
        font-weight: bold;
    }
    .chosed-job-type .van-grid-item__content{
        background:url("/__FRONT__/images/icon/check-job-type.png") no-repeat;
        background-size: 100%;
    }

    .van-cell-li{
        padding-top: 0px;
        padding-bottom: 0px;
        padding-right: 0px;
        min-height: 44px;
    }
    .van-cell-li .van-cell__left-icon{
        display: inline-block;
        padding-top: 10px;
    }
    .van-cell-li .van-cell__title span{
        display: inline-block;
        padding-top: 10px;
    }
    .van-cell-li .van-cell__value .van-field{
        background-color: #2aa24512;
        padding: 8px 10px;
        margin-top: 1px;
    }


    .job-detail-title-cell{
        padding: 3px 16px;
    }

    .job-detail-title{
        font-size: 18px;
        font-weight: 500;
    }

    .job-detail-money-cell{
        margin-top: 2px;
    }
    .job-detail-money{
        display: block;
        padding: 5% 10%;
    }
    .job-detail-money span{
        display: block;
        text-align: center;
        padding: 2% 0%;
    }
    .job-detail-article{
        font-size: .8rem;
        color: #2a2a2c;
        padding: 0% 4%;
    }

    .thirdStep-cell-li .van-cell__title{
        max-width: 26%;
    }

    .money-unit-btn{
        margin-left: 1.5%;
        margin-right: 1.5%;
        margin-bottom: 2%;
        border: 1px solid #a8a8a8;
    }
    .chose-money-unit-btn{
        background-color: #2aa245;
        color: #fff;
        font-size: 14px;
        font-weight: bold;
    }



</style>


<div id="app"  v-cloak>

    <van-nav-bar title="发布兼职岗位" left-arrow @click-left="goBack" left-text="返回"></van-nav-bar>

    <van-row>
        <van-col span="24">
            <van-steps
                    :active="currentStep"
                    active-icon="success"
            >
                <van-step>
                    <span class="step-span">兼职类型</span>
                </van-step>
                <van-step>
                    <span class="step-span">兼职详细</span>
                </van-step>
                <van-step>
                    <span class="step-span">预览发布</span>
                </van-step>
            </van-steps>
        </van-col>
    </van-row>


    <!--第一步-->
    <section v-show="firstStep">
        <van-row style="padding-bottom: 55px;">
            <van-cell
                    title="您需要什么类型的人才"
                    is-link arrow-direction="down"
                    icon="/__FRONT__/images/icon/publish-job-question.png"
                    style="font-weight: bold;font-size: 16px;"
            ></van-cell>

            <van-col span="24">
                <!--兼职类型-->
                <van-row>
                    <van-grid :column-num="4" square :border="false">
                        <van-grid-item
                                v-for="item in jobsType"
                                :icon="item.img"
                                :text="item.name"
                                :class="item.style"
                                @click="clickJobType(item)"
                        />
                    </van-grid>
                </van-row>
                <!--兼职类型-->

            </van-col>
        </van-row>
        <van-goods-action>
            <van-goods-action-button
                    type="danger"
                    text="下一步"
                    @click="firstStepBtn"
                    style="border-radius: 0px; margin-left: 0px;margin-right: 0px;"
                    color="#fc2820"
            />
        </van-goods-action>
    </section>
    <!--第一步-->


    <!--第二步-->
    <section v-show="secondStep">
        <div style="padding-bottom: 55px;">
            <van-row>
                <van-cell
                        title="兼职标题"
                        icon="/__FRONT__/images/icon/publish-job-title.png"
                        style="font-weight: bold;font-size: 16px;"
                        :border="false"
                ></van-cell>
                <van-cell-group style="border: 1px solid #2aa24512; ">
                    <van-field
                            v-model="jobInfo.title" placeholder="请输入兼职标题"
                            required clearable
                            maxlength="20"
                            input-align="center"
                            border="false"
                            style="background-color: #2aa24512;"
                    ></van-field>
                </van-cell-group>
            </van-row>

            <van-row>
                <van-cell-group>
                    <van-cell
                            title="招聘对象"
                            icon="/__FRONT__/images/icon/publish-job-sex.png"
                            is-link
                            :value="getSelectGender"
                            @click="clickShowSelectGender"
                    ></van-cell>

                    <van-cell
                            title="兼职开始日期："
                            icon="/__FRONT__/images/icon/publish-job-time.png"
                            is-link
                            :value="getSelectTimeStart"
                            @click="clickShowSelectTimeStart"
                    >
                    </van-cell>

                    <van-cell
                            title="兼职结束日期："
                            icon="/__FRONT__/images/icon/publish-job-time.png"
                            is-link
                            :value="getSelectTimeEnd"
                            @click="clickShowSelectTimeEnd"
                    >
                    </van-cell>

                    <van-cell
                            title="上班时间："
                            icon="/__FRONT__/images/icon/publish-job-time.png"
                            is-link
                            :value="jobInfo.work_up_time"
                            @click="clickWorkUpTime"
                    >
                    </van-cell>


                    <van-cell
                            title="下班时间："
                            icon="/__FRONT__/images/icon/publish-job-time.png"
                            is-link
                            :value="jobInfo.work_down_time"
                            @click="clickWorkDownTime"
                    >
                    </van-cell>




                    <van-cell
                            title="薪资："
                            icon="/__FRONT__/images/icon/publish-job-money.png"
                            class="van-cell-li"
                    >
                        <van-field
                                v-model="jobInfo.salary"
                                input-align="center"
                                type="number"
                                slot="default"
                                border="false"
                                placeholder="请输入待遇薪资"
                        >
                            <van-icon slot="right-icon" style="font-size: 14px;font-weight: bold;">元</van-icon>
                        </van-field>

                    </van-cell>


                    <van-col span="24" style="text-align: center;">
                        <template v-for="(item) in moneyUnit">
                            <van-button type="default" size="small" :class="item.class" @click="choseMoneyUnit(item)">
                                {{item.text.replace('/元', '')}}
                            </van-button>
                        </template>
                    </van-col>




                    <van-cell
                            title="招聘几人："
                            icon="/__FRONT__/images/icon/publish-job-person-num.png"
                            class="van-cell-li"
                    >
                        <van-field
                                v-model="jobInfo.need_worker"
                                input-align="center"
                                type="number"
                                slot="default"
                                border="false"
                        >
                            <van-icon slot="right-icon" style="font-size: 14px;font-weight: bold;">人</van-icon>
                        </van-field>

                    </van-cell>


                    <van-cell
                            title="结算方式："
                            icon="/__FRONT__/images/icon/publish-job-time.png"
                            is-link
                            :value="getSettlement"
                            @click="clickShowSelectSettlement"
                    >
                    </van-cell>



                    <van-cell
                            title="招聘人："
                            icon="/__FRONT__/images/icon/publish-job-contacts.png"
                            class="van-cell-li"
                    >
                        <van-field
                                v-model="jobInfo.contacts"
                                input-align="center"
                                slot="default"
                                border="false"
                        >
                        </van-field>
                    </van-cell>

                    <van-cell
                            title="联系方式："
                            icon="/__FRONT__/images/icon/job-detail-mobile.png"
                            class="van-cell-li"
                    >
                        <van-field
                                v-model="jobInfo.mobile"
                                input-align="center"
                                slot="default"
                                type="number"
                                border="false"
                                @blur="checkPhoneNum"
                                :error-message="phone.error"
                        >
                        </van-field>

                    </van-cell>

                    <van-cell
                            title="兼职区域："
                            icon="/__FRONT__/images/icon/publish-job-area.png"
                            is-link
                            :value="getLocation"
                            @click="clickShowSelectArea"
                    >
                    </van-cell>

                    <van-cell
                            title="兼职详细地址："
                            icon="/__FRONT__/images/icon/publish-job-address.png"
                            class="van-cell-li"
                    >
                        <van-field
                                v-model="jobInfo.address"
                                input-align="center"
                                placeholder="请输入详细地址"
                                type="text"
                                slot="default"
                                border="false"
                        >
                        </van-field>

                    </van-cell>

                </van-cell-group>
            </van-row>

            <van-row>
                <van-cell
                        title="工作内容"
                        icon="/__FRONT__/images/icon/job-detail-content.png"
                        style="font-weight: bold;font-size: 16px;"
                        :border="false"
                ></van-cell>
                <van-cell-group style="border: 1px solid #2aa24512; ">
                    <van-field
                            v-model="jobInfo.content"
                            rows="3"
                            type="textarea"
                            maxlength="750"
                            placeholder="请输入该兼职需要处理什么事物?"
                            show-word-limit
                            style="background-color: #2aa24512;"
                    ></van-field>
                </van-cell-group>
            </van-row>


            <van-row>
                <van-cell
                        title="工作要求"
                        icon="/__FRONT__/images/icon/job-detail-require.png"
                        style="font-weight: bold;font-size: 16px;"
                        :border="false"
                ></van-cell>
                <van-cell-group style="border: 1px solid #2aa24512; ">
                    <van-field
                            v-model="jobInfo.requirement"
                            rows="3"
                            type="textarea"
                            maxlength="750"
                            placeholder="请输入该兼职需要什么特殊要求?"
                            show-word-limit
                            style="background-color: #2aa24512;"
                    ></van-field>
                </van-cell-group>
            </van-row>


            <van-row>
                <van-cell
                        title="工作福利"
                        icon="/__FRONT__/images/icon/job-detail-welfare.png"
                        style="font-weight: bold;font-size: 16px;"
                        :border="false"
                ></van-cell>
                <van-cell-group style="border: 1px solid #2aa24512; ">
                    <van-field
                            v-model="jobInfo.work_welfare"
                            rows="3"
                            type="textarea"
                            maxlength="750"
                            placeholder="该兼职有哪些诱人福利？"
                            show-word-limit
                            style="background-color: #2aa24512;"
                    ></van-field>
                </van-cell-group>
            </van-row>
        </div>


        <van-goods-action>
            <van-goods-action-button
                    type="danger"
                    text="上一步"
                    @click="backFirstStopBtn"
                    style="border-radius: 0px;margin-left: 0px;"
                    color="#33a04a"
            ></van-goods-action-button>
            <van-goods-action-button
                    type="danger"
                    text="下一步"
                    @click="secondStepBtn"
                    style="border-radius: 0px;margin-right: 0px;"
                    color="#fc2820"
            ></van-goods-action-button>
        </van-goods-action>
    </section>
    <!--第二步-->






    <!--第三步-->
    <section v-show="thirdStep">
        <div style="padding-bottom: 55px;">
            <van-row>
                <van-col span="18">
                    <van-cell :border="false" class="job-detail-title-cell">
                        <span class="van-ellipsis job-detail-title" :title="jobInfo.title">{{jobInfo.title}}</span>
                    </van-cell>
                    <van-cell  icon="/__FRONT__/images/icon/baozhang.png" :border="false"  class="job-detail-title-cell">
                        <van-tag type="success">平台认证</van-tag>
                    </van-cell>
                    <van-cell :border="false"  class="job-detail-title-cell">
                        <span>招聘人数：{{jobInfo.need_worker}}人</span>
                    </van-cell>
                </van-col>

                <van-col span="6" class="job-detail-money-cell">
                    <van-tag plain class="job-detail-money">
                        <span class="money-font" style="font-size: 22px;color: #fe9e39;">{{jobInfo.salary}}</span>
                        <span>{{jobInfo.salary_unitCh}}</span>
                        <span style="color: #2a2a2c;font-weight: bold;">{{jobInfo.settlement_typeCh}}</span>
                    </van-tag>
                </van-col>
            </van-row>

            <van-divider :style="{borderColor: '#32a14a', padding: '0 16px' }"></van-divider>

            <van-cell :title="getSetp3Location"
                      icon="/__FRONT__/images/icon/location-icon.png"
                      style="padding-top: 0px;"
                      :border="false"
            ></van-cell>


            <van-row>
                <van-cell title="兼职详情" icon="/__FRONT__/images/icon/job-detail-icon.png" size="large">
                    <van-icon name="arrow-down"></van-icon>
                </van-cell>
                <van-cell title="兼职类型:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/job-type-qt.png"
                          :value="jobInfo.work_typeCh">
                </van-cell>
                <van-cell title="详细地址:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/publish-job-address.png"
                          :value="jobInfo.address">
                </van-cell>
                <van-cell title="工作开始日期:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/publish-job-time.png"
                          :value="jobInfo.work_timeCh">
                </van-cell>
                <van-cell title="工作结束日期:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/publish-job-time.png"
                          :value="jobInfo.work_time_endCh">
                </van-cell>
                <van-cell title="上班时间:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/publish-job-time.png"
                          :value="jobInfo.work_up_time">
                </van-cell>
                <van-cell title="下班时间:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/publish-job-time.png"
                          :value="jobInfo.work_down_time">
                </van-cell>

                <van-cell title="性别要求:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/publish-job-sex.png"
                          :value="jobInfo.genderCh">
                </van-cell>
                <van-cell title="联系人:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/publish-job-contacts.png"
                          :value="jobInfo.contacts">
                </van-cell>
                <van-cell title="联系方式:"
                          class="thirdStep-cell-li"
                          icon="/__FRONT__/images/icon/job-detail-mobile.png"
                          :value="jobInfo.mobile">
                </van-cell>
                <van-cell >
                    <van-icon name="/__FRONT__/images/icon/job-detail-welfare.png"></van-icon>
                    <span style="color: #323233; text-align: left;">福利:</span>
                    <div class="van-multi-ellipsis--l3">{{jobInfo.work_welfare}}</div>
                </van-cell>
            </van-row>


            <van-row>
                <van-cell title="工作要求" icon="/__FRONT__/images/icon/job-detail-require.png" size="30px">
                    <van-icon name="arrow-down"></van-icon>
                </van-cell>
                <van-col span="24">
                    <article class="job-detail-article">
                        <p>{{jobInfo.requirement}}</p>
                    </article>
                </van-col>
            </van-row>

            <van-row>
                <van-cell title="工作内容" icon="/__FRONT__/images/icon/job-detail-content.png" size="30px">
                    <van-icon name="arrow-down"></van-icon>
                </van-cell>
                <van-col span="24">
                    <article class="job-detail-article">
                        <p>{{jobInfo.content}} </p>
                    </article>
                </van-col>
            </van-row>

        </div>



        <van-goods-action>
            <van-goods-action-button
                    type="danger"
                    text="上一步"
                    style="border-radius: 0px;margin-left: 0px;"
                    color="#33a04a"
                    @click="backSecondStopBtn"
            ></van-goods-action-button>
            <van-goods-action-button
                    type="danger"
                    text="保存草稿"
                    style="border-radius: 0px;margin-left: 0px;"
                    color="#737373"
                    @click="saveJobDraft"
            ></van-goods-action-button>
            <van-goods-action-button
                    type="danger"
                    text="发布"
                    style="border-radius: 0px;margin-right: 0px;"
                    color="#fc2820"
                    @click="publishJob"
            ></van-goods-action-button>
        </van-goods-action>
    </section>
    <!--第三步-->




    <!--性别选择器-->
    <van-popup
            v-model="showSelectGender"
            position="bottom"
    >
        <van-picker
                show-toolbar
                :columns="jobsGender"
                @cancel="showSelectGender = false"
                @confirm="confirmSelectGender"
        ></van-picker>

    </van-popup>
    <!--性别选择器-->


    <!--兼职开始时间选择器-->
        <van-calendar
            v-model="showSelectTimeStart"
            type="single"
            @confirm="confirmSelectTimeStart"
        >
        </van-calendar>
    <!--兼职开始时间选择器-->

    <!--兼职结束时间选择器-->
    <van-calendar
            v-model="showSelectTimeEnd"
            type="single"
            @confirm="confirmSelectTimeEnd"
    >
    </van-calendar>
    <!--兼职结束时间选择器-->



    <!--上班时间-->
    <van-popup
            v-model="showWorkUpTime"
            position="bottom"
    >
        <van-datetime-picker
                v-model="jobInfo.work_up_time"
                type="time"
                :min-hour="0"
                :max-hour="23"
                @cancel="showWorkUpTime = false"
                @confirm="confirmWorkUpTime"
        >
        </van-datetime-picker>
    </van-popup>
    <!--上班时间-->

    <!--下班时间-->
    <van-popup
            v-model="showWorkDownTime"
            position="bottom"
    >
        <van-datetime-picker
                v-model="jobInfo.work_down_time"
                type="time"
                :min-hour="0"
                :max-hour="23"
                @cancel="showWorkDownTime = false"
                @confirm="confirmWorkDownTime"
        >
        </van-datetime-picker>
    </van-popup>
    <!--下班时间-->



    <!--结算方式选择器-->
    <van-popup
            v-model="showSelectSettlement"
            position="bottom"
    >
        <van-picker
            show-toolbar
            :columns="settlementList"
            @cancel="showSelectSettlement = false"
            @confirm="confirmSelectSettlement"
        ></van-picker>
    </van-popup>
    <!--结算方式选择器-->

    <!--区域方式选择器-->
    <van-popup
            v-model="showSelectArea"
            position="bottom"
    >
        <van-area
            :area-list="selectArea"
            @cancel="showSelectArea = false"
            @confirm="confirmSelectArea"
        ></van-area>
    </van-popup>
    <!--区域选择器-->





</div>



<script>

    Vue.use(vant.Lazyload);

    var vm = new Vue({
        //挂载点
        el: '#app',
        //数据集合
        data() {
            return {
                currentStep: 0,
                firstStep: true,
                secondStep: false,
                thirdStep: false,

                //显示选择性别pop
                showSelectGender: false,
                //显示选择日期pop
                showSelectTimeStart: false,
                showSelectTimeEnd: false,

                //显示上下班时间
                showWorkUpTime: false,
                showWorkDownTime: false,

                //显示选择结算方式
                showSelectSettlement: false,
                //显示选择地区
                showSelectArea: false,

                //工作详细
                jobInfo:{
                    id: {$jobId},
                    work_type: 0,
                    work_typeCh: '',
                    title: '',
                    salary: '',
                    salary_unit: '',
                    salary_unitCh: '',
                    need_worker: '',
                    mobile: '',
                    contacts: '',
                    work_time: '',
                    work_timeCh: '',
                    work_time_end: '',
                    work_time_endCh: '',
                    work_up_time: '',
                    work_down_time: '',
                    gender: 0,
                    genderCh:'男女不限',
                    provinces_name: '',
                    address: '',
                    settlement_type: '',
                    settlement_typeCh: '',
                    content: '',
                    requirement: '',
                    work_welfare: '',
                    extend_id: 0

                },

                jobsGender:[],
                jobsType:[],
                moneyUnit: [],
                settlementList: [],
                selectArea: {},

                selectMinDate: new Date(),

                phone:{
                    error: '',
                },

                //是否提交
                isPost:false,

            }
        },

        //创建时执行 操作
        created : function (){
            //获取兼职类型列表
            axiosRequest.get('/api/job/jobType').then(function (response) {
                if (response.code == 200) {
                    response.data.forEach(function (item) {
                        item.style = '';
                    });
                    vm.$data.jobsType = response.data;

                    vm.fillChoseJobType();
                } else {
                    vant.Notify({ type: 'danger', message: response.msg });
                }
            });

            //获取系统中开放的地区
            axiosRequest.get('/api/common/openArea').then(function (response) {
                if (response.code == 200) {
                    vm.$data.selectArea = response.data;
                }
            });

            //获取发布兼职需要的数据
            axiosRequest.get('/api/job/publishNeedData').then(function (response) {
                if (response.code == 200) {
                    //添加数据
                    response.data.moneyUnit.forEach(function (item) {
                        item.class = ['money-unit-btn'];
                    });
                    vm.$data.jobsGender = response.data.gender;
                    vm.$data.moneyUnit = response.data.moneyUnit;
                    vm.$data.settlementList = response.data.settlement;
                }
            });


            //获取兼职详情
            if (this.jobInfo.id) {
                var params = {
                    id: this.jobInfo.id,
                    extend: 'content,publishUser'
                };
                axiosRequest.get('/api/job/detail',{params:params}).then(function (response) {
                    if (response.code == 200) {
                        vm.$data.jobInfo = response.data;
                        vm.$data.jobInfo.content = response.data.extendContent.content;
                        vm.$data.jobInfo.requirement = response.data.extendContent.requirement;
                        vm.$data.jobInfo.work_welfare = response.data.extendContent.work_welfare;
                        vm.$data.jobInfo.salary = parseFloat(vm.$data.jobInfo.salary);
                        vm.fillChoseWorkTime();
                        vm.fillChoseMoneyUnit();
                        vm.fillChoseJobType();
                    } else {
                        vant.Toast({
                            message: response.msg,
                            onClose: function () {
                                history.back();
                            }
                        });
                    }
                });
            }


        },

        mounted(){
        },

        //计算属性
        computed:{
            workLocation(){

            },
            getSelectGender() {
                return this.jobInfo.genderCh ? this.jobInfo.genderCh : '男女不限';
            },
            getSelectTimeStart()
            {
                return this.jobInfo.work_timeCh ? this.jobInfo.work_timeCh : '请选择开始日期';
            },
            getSelectTimeEnd()
            {
                return this.jobInfo.work_time_endCh ? this.jobInfo.work_time_endCh : '请选择结束日期';
            },
            getSettlement(){
                return this.jobInfo.settlement_typeCh ? this.jobInfo.settlement_typeCh : '请选择结算方式';
            },
            getLocation(){
                return this.jobInfo.provinces_name ? this.jobInfo.provinces_name : '请选择区域';
            },
            getSetp3Location(){
                return this.jobInfo.provinces_name + ' ' + this.jobInfo.address;
            }
        },



        //方法集合 在 `methods` 对象中定义方法
        methods: {
            //返回上一页
            goBack(){
                history.back();
            },


            //检测手机号码
            checkPhoneNum(){
                var reg = /^1(1|3|4|5|6|7|8|9)\d{1}[-]?\d{4}[-]?\d{4}$/;
                if(!reg.test(this.jobInfo.mobile)){
                    this.phone.error = '请输入正确的电话号码!';
                } else {
                    this.phone.error = '';
                }
            },
            //编辑 - 填充选择好的兼职类型
            fillChoseJobType(){
                if (this.jobInfo.id) {
                    this.jobsType.forEach(function (item) {
                        if (item.id == vm.$data.jobInfo.work_type) {
                            item.style = 'chosed-job-type';
                            vm.$data.jobInfo.work_typeCh = item.name;
                        }
                    });
                }
            },
            //编辑 - 填充选择好的薪资单位
            fillChoseMoneyUnit(){
                if (this.jobInfo.id) {
                    this.moneyUnit.forEach(function (item) {
                        if (item.index == vm.$data.jobInfo.salary_unit) {
                            item.class = ['money-unit-btn', 'chose-money-unit-btn'];
                        }
                    });
                }
            },
            //编辑 - 填充时间
            fillChoseWorkTime(){
                if (this.jobInfo.id) {
                    this.jobInfo.work_time = new Date(parseInt(this.jobInfo.work_time) * 1000);
                }
            },


            clickJobType(choseItem){
                this.jobsType.forEach(function (item) {
                    item.style = '';
                });
                choseItem.style = 'chosed-job-type';
                this.jobInfo.work_type = choseItem.id;
                this.jobInfo.work_typeCh = choseItem.name;
            },

            //第一步
            firstStepBtn(){
                if (!this.jobInfo.work_type) {
                    vant.Notify({type: 'danger', message: '请先选择兼职类型,在进行下一步操作!'});
                    vant.Toast('请先选择兼职类型!');

                } else {
                    this.firstStep = false;
                    this.secondStep = true;
                    this.currentStep = 1;
                }
            },
            backFirstStopBtn(){
                this.firstStep = true;
                this.secondStep = false;
                this.currentStep = 0;
            },


            //第二步
            secondStepBtn(){
                var mustNotEmpey = [
                    {
                        field: 'title',
                        errorMsg: '请填写标题信息!',
                    },
                    {
                        field: 'salary',
                        errorMsg: '请填写待遇薪资！',
                    },
                    {
                        field: 'salary_unit',
                        errorMsg: '请选择待遇薪资方式!',
                    },
                    {
                        field: 'need_worker',
                        errorMsg: '请填写招聘人数！',
                    },
                    {
                        field: 'mobile',
                        errorMsg: '请填写招聘方联系方式!',
                    },
                    {
                        field: 'contacts',
                        errorMsg: '请填写招聘方联系人!',
                    },
                    {
                        field: 'work_time',
                        errorMsg: '请填写兼职时间!',
                    },
                    {
                        field: 'content',
                        errorMsg: '请填写兼职内容!',
                    },
                    {
                        field: 'address',
                        errorMsg: '请填写兼职具体地点!',
                    },
                    {
                        field: 'requirement',
                        errorMsg: '请填写兼职要求!',
                    },
                    {
                        field: 'provinces_name',
                        errorMsg: '请选择兼职所在区域！',
                    },
                ];
                for(var item of mustNotEmpey) {
                    if (!this.jobInfo[item.field]) {
                        vant.Toast(item.errorMsg);
                        return false;
                    }
                }
                this.secondStep = false;
                this.thirdStep = true;
                this.currentStep = 2;
            },

            backSecondStopBtn(){
                this.thirdStep = false;
                this.secondStep = true;
                this.currentStep = 1;
            },

            //保存到草稿
            saveJobDraft(){
                var postData = this.getPostData();
                vant.Toast.loading({
                    duration: 0,
                    overlay: true,
                    forbidClick: true,
                    message: '正在保存...'
                });
                axiosRequest.post('/api/job/saveDraft', postData).then(function (response) {
                    vant.Toast.clear();
                    if (response.code == 200) {
                        vm.jobInfo.id = response.data.jobId;
                        vm.jobInfo.extend_id = response.data.extendId;
                        vant.Toast({
                            message: '已保存为草稿！',
                            onClose(){
                                window.location.href = '/index/Usercenter/publishJobList?type=0';
                            }
                        });
                    } else {
                        vant.Toast('保存失败！');
                        vant.Notify({type:'danger', message:response.msg});
                    }
                });
                return true;
            },

            getPostData(){
                var jobPostData = {
                    extendId: this.jobInfo.extend_id,
                    id: this.jobInfo.id,
                    work_type: this.jobInfo.work_type,
                    contacts: this.jobInfo.contacts,
                    mobile: this.jobInfo.mobile,
                    title: this.jobInfo.title,
                    work_time: (Date.parse(this.jobInfo.work_time) / 1000),
                    work_time_end: (Date.parse(this.jobInfo.work_time_end) / 1000),
                    work_up_time: this.jobInfo.work_up_time,
                    work_down_time: this.jobInfo.work_down_time,
                    address: this.jobInfo.address,
                    provinces_name: this.jobInfo.provinces_name,
                    salary: this.jobInfo.salary,
                    salary_unit: this.jobInfo.salary_unit,
                    need_worker: this.jobInfo.need_worker,
                    settlement_type: this.jobInfo.settlement_type,
                    gender: this.jobInfo.gender,
                    content: this.jobInfo.content,
                    requirement: this.jobInfo.requirement,
                    work_welfare: this.jobInfo.work_welfare
                };
                return jobPostData;
            },

            //保存发布
            publishJob(){
                if (!this.isPost) {
                    var postData = this.getPostData();
                    vant.Toast.loading({
                        duration: 0,
                        overlay: true,
                        forbidClick: true,
                        message: '正在提交...'
                    });
                    axiosRequest.post('/api/job/publishJob', postData).then(function (response) {
                        vant.Toast.clear();
                        if (response.code == 200) {
                            vm.$data.isPost = true;
                            vant.Toast({
                                message: '发布成功,请等待审核!',
                                onClose(){
                                    window.location.href = '/index/Usercenter/publishJobList?type=1';
                                }
                            });

                        } else {
                            if (response.code == 200006) {
                                vant.Dialog.confirm({
                                    message: response.msg,
                                    confirmButtonText: '去充值',
                                    cancelButtonText: '先保存草稿'
                                }).then(() => {
                                    window.location.href = '/index/Userwallet/buyBean';
                                }).catch(() => {
                                });
                            } else {
                                vant.Notify({type:'danger', message:response.msg});
                            }
                        }
                    });
                }
            },


            /** popup  选择 工具 start */

            //选择男女
            clickShowSelectGender(){
                this.showSelectGender = true;
            },
            confirmSelectGender(item, index){
                this.jobInfo.gender = index;
                this.jobInfo.genderCh = item;
                this.showSelectGender = false;
            },

            //选择兼职开始时间
            clickShowSelectTimeStart(){
                this.showSelectTimeStart = true;
            },
            confirmSelectTimeStart(value){
                var startTime = value;
                var startYear = startTime.getFullYear() + '年';
                var startMonth = (startTime.getMonth() + 1) + '月';
                var startDay = startTime.getDate() + '日';

                this.jobInfo.work_timeCh = startMonth + '/' + startDay;
                this.jobInfo.work_time = startTime;
                this.showSelectTimeStart = false;
            },
            //选择兼职结束时间
            clickShowSelectTimeEnd(){
                this.showSelectTimeEnd = true;
            },
            confirmSelectTimeEnd(value){
                var endTime = value;
                var endYear = endTime.getFullYear() + '年';
                var endMonth = (endTime.getMonth() + 1) + '月';
                var endDay = endTime.getDate() + '日';

                this.jobInfo.work_time_endCh = endMonth + '/' + endDay;
                this.jobInfo.work_time_end = endTime;
                this.showSelectTimeEnd = false;
            },


            //选择上班时间
            clickWorkUpTime(){
                this.showWorkUpTime = true;
            },
            confirmWorkUpTime(value){
                this.showWorkUpTime = false;
            },
            //选择下班时间
            clickWorkDownTime(){
                this.showWorkDownTime = true;
            },
            confirmWorkDownTime(value){
                this.showWorkDownTime = false;
            },

            //选择结算方式
            clickShowSelectSettlement(){
                this.showSelectSettlement = true;
            },
            confirmSelectSettlement(item){
                this.jobInfo.settlement_type = item.index;
                this.jobInfo.settlement_typeCh = item.text;
                this.showSelectSettlement = false;
            },

            //选择兼职地区
            clickShowSelectArea(){
                this.showSelectArea = true;
            },
            confirmSelectArea(item){
                this.jobInfo.provinces_name = '';
                item.forEach(function(one){
                    vm.$data.jobInfo.provinces_name += ' ' + one.name;
                });
                this.showSelectArea = false;
            },

            //选择薪资单位
            choseMoneyUnit(item){
                this.moneyUnit.forEach(function(one){
                    one.class = ['money-unit-btn'];
                });
                this.jobInfo.salary_unit = item.index;
                this.jobInfo.salary_unitCh = item.text;
                item.class = ['money-unit-btn', 'chose-money-unit-btn'];
            }
            /** popup  选择 工具 start */

        }

    });
</script>


{include file="common/foot-bottom" /}
